package org.footballmanager.pandafootball.system.form.impl;

import lombok.Getter;
import lombok.Setter;
import org.footballmanager.pandafootball.system.domain.FootError;
import org.footballmanager.pandafootball.system.domain.enums.ERFL;
import org.footballmanager.pandafootball.system.domain.enums.ERZT;
import org.footballmanager.pandafootball.system.form.SearchForm;
import org.springframework.util.StringUtils;
import tk.mybatis.mapper.entity.Example;

import java.io.Serializable;

@Getter
@Setter
public class FootErrorSearchForm extends SearchForm implements Serializable {
    private static final long serialVersionUID = 8090668615941861528L;
    protected String gnjs;
    protected ERFL erfl;
    protected Integer yxj;
    protected ERZT erzt;

    public Example buildSearchCommond() {
        Example example = new Example(FootError.class);
        Example.Criteria criteria = example.createCriteria();
        if (!StringUtils.isEmpty(gnjs)) {
            criteria.andLike("gnjs", "%" + gnjs.trim() + "%");
            Example.Criteria criteria2 = example.createCriteria();
            criteria2.andEqualTo("ms", gnjs.trim());
            example.or(criteria2);
        }
        if (erzt != null) {
            criteria.andEqualTo("erzt", erzt);
        }
        if (erfl != null) {
            criteria.andEqualTo("erfl", erfl);
        }
        if (yxj != null) {
            criteria.andEqualTo("yxj", yxj);
        }
        criteria.andEqualTo("delFlag", 0);
        example.orderBy("yxj").desc();
        return example;
    }

}
